import numpy as np

arr = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])

print(arr)
print(type(arr))

print(arr[:, 1:2])

arr[:, 1:2] = 0
print(arr)

print(arr * 2)
print(arr / 2)
print(arr + 2)
print(arr - 2)
print(arr // 2)
print(arr ** 2)
print(arr % 2)

print(arr.shape)

arr2 = arr > 5
print(arr2)

# bool 索引
print(arr[arr > 5])

arr = np.array([[1, 2, 3], [4, 5, 6]])

print(arr)
print(arr.T)

print(arr[::, ::-1])

print(np.fliplr(arr))

arr1 = np.array([[2, 2, 2], [2, 2, 2]])
arr2 = np.array([[5, 5, 5], [5, 5, 5]])

#  对位运算
print(arr1 + arr2)
print(arr1 - arr2)
print(arr1 * arr2)
print(arr1 / arr2)

arr = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])

print(np.sin(arr))
print(np.log2(arr))

arr = np.array([1, 2, 3, 4, 5, 6, 7])

print(np.diff(arr, n=1))

arr = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
print(arr)
print(np.diff(arr, axis=0))
print(np.diff(arr, axis=1))

arr = np.array([1, 2, 3, 4, 5, 6, 7])
arr1 = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
print(np.amax(arr))
print(np.amin(arr))
print(np.mean(arr))

print(np.mean(arr1, axis=0))
